package controller

import (
	"github.com/gin-gonic/gin"
	"go-demo/service"
	"go-demo/util"
)

type AuditLogController struct {
	AuditLogAppService *service.AuditLogAppService
}

func NewAuditLogController(auditLogAppService *service.AuditLogAppService) *AuditLogController {
	return &AuditLogController{
		AuditLogAppService: auditLogAppService,
	}
}

// GetList
// @Summary
// @Description
// @Tags 审计日志
// @Accept  json
// @Produce  json
// @Param input query service.GetListAuditLogInput  true  "GetListAuditLogInput"
// @Success 200 {object} service.GetListAuditLogOutput
// @Router /AuditLog [get]
func (ctl *AuditLogController) GetList(ctx *gin.Context) {
	var input service.GetListAuditLogInput
	if err := ctx.ShouldBindQuery(&input); err != nil {
		util.Json(ctx, nil, err)
		return
	}
	output, code, err := ctl.AuditLogAppService.GetList(ctx, &input)
	util.JsonWithCode(ctx, output, code, err)
}

// GetOne
// @Summary
// @Description
// @Tags 审计日志
// @Accept  json
// @Produce  json
// @Param  id  	 	    path   	string 	 true 	"id"
// @Success 200 {object} service.AuditLogDto
// @Router /AuditLog/{id} [get]
func (ctl *AuditLogController) GetOne(ctx *gin.Context) {
	id := ctx.Param("id")
	output, code, err := ctl.AuditLogAppService.GetOne(ctx, id)
	util.JsonWithCode(ctx, output, code, err)
}
